package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.Orders;
import com.sky.vo.OrderVO;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface OrdersMapper {
    /**
     * 插入订单数据
     * @param orders
     */
    void insert(Orders orders);

    /**
     * 根据订单号和用户id查询订单
     * @param orderNumber
     * @param userId
     */
    @Select("select * from orders where number = #{orderNumber} and user_id= #{userId}")
    Orders getByNumberAndUserId(String orderNumber, Long userId);

    /**
     * 修改订单信息
     * @param orders
     */
    void update(Orders orders);
    Page<OrderVO> conditionSearch(OrdersPageQueryDTO dto);

    /**
     * 分页查询
     * @param dto
     * @return
     */
    Page<OrderVO> page(OrdersPageQueryDTO dto);

    /**
     * 根据id查询
     * @param id
     * @return
     */
    Orders getById(Long id);

    /**
     * 取消订单
     * @param orders
     */
    void updateStatus(Orders orders);

    //查询待派送数量
    @Select("select count(*) from orders where status = 3;")
    Integer countConfirmed();

    //查询派送中数量
    @Select("select count(*) from orders where status = 4;")
    Integer countDeliveryInProgress();

    //查询待接单数量
    @Select("select count(*) from orders where status = 2;")
    Integer countToBeConfirmed();




}
